﻿@model IEnumerable<YGLAB_SON.Models.UserProfile>

@{
    ViewBag.Title = "Yazar";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<div id="searchUserForm">
    @using (Html.BeginForm("Yazar", "Ara", FormMethod.Get))
    {   
    <p>
        @Html.TextBox("searchUser")
        <input type="submit" value="Ara" />
    </p>     
    }
</div>

@if (Model.Any()) // Model is an IEnumerable<User>
{
    <table>
  <tr>
             <th>Kullanıcı Id</th>
             <th> Kullanıcı Adı</th>
             <th>Email</th>
             <th>Kullanıcı Rolleri</th>
        <th>İşlemler</th>
    </tr>
    @foreach (var item in Model)
    {
     string[] roller = Roles.GetRolesForUser( item.UserName );
        <tr>
            <td>
                @Html.DisplayFor( m => item.UserId )
            </td>
            <td>
                @Html.DisplayFor( m => item.UserName )
            </td>
            <td>
                @Html.DisplayFor( m => item.Email )
            </td>
            <td>
               @foreach( var rol in roller ) { 
                   <span>
                       @rol;
                   </span>
                
               }
            </td>
            <td>
                @if( item.UserName != "Admin") {
                     @Html.ActionLink( "Sil" , "Sil", "Kullanici",new { username = item.UserName }, null)
                    @Html.ActionLink( "Rolleri Düzenle" , "Roller", "Kullanici",new { username = item.UserName }, null)
                }
               
            </td>
        </tr>
    }
    </table>
}
else 
{
    <p>Yazar bulunamadı</p>
}